using System;
using FluentNHibernate.Automapping;
using FluentNHibernate.Automapping.Alterations;
using MvcMall.Core.Domains;
using MvcMall.Core.Enums;

namespace MvcMall.Data.NHibernateMaps
{
    public class RegionMap : IAutoMappingOverride<Region>
    {
        public void Override(AutoMapping<Region> mapping)
        {
            mapping.References(c => c.ParentRegion).Column("ParentId");
            mapping.HasMany(c => c.ChildRegions).KeyColumn("ParentId");
            mapping.Map(m => m.RegionType).CustomType(typeof (RegionType));
        }
    }
}